// https://mp.weixin.qq.com/s/AIifvclv-YDZ-z7EEgjv3Q

// https://www.cnblogs.com/zxin/archive/2013/01/26/2877765.html

// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions

// 常见的自己写的即可。 开发要用的话，直接查看CSDN
const reg = /^\d*$/;

const reg1 = /$\d{0,}$/;

console.log(reg.test(""));

const foo = (params, name) => {
  console.log(params, name ?? "12312");
};

foo(123);

// replace 只替换一个
const test = /\//g;

console.log("123123////".replace(test, "4"));

// 标识唯一
let id = Symbol("id");
console.log(id);
console.log(id.toString());

let obj = {
  name: "1231",
};
obj[id] = "zs";

console.log(obj[id]);
// 第二种添加方式。
let obj1 = {
  name: "lisi",
  [id]: "private",
};

// console.log("obj1", obj1[id], obj1.id);

// 字符串，替换
// 字符串，替换(全局替换多个，否则只会替换一个)
const regg = /(\[ | \])/;

const data = [12312, [23423, 23423]];

const resp = data.toString().replace(regg, "");

const resp1 = data.toString().replace(12312, "zzzz");
const resp2 = data.toString().replace(/12312/, "xxxx");

console.log(resp);
console.log(resp1);
console.log(resp2);

// Create a new object, that prototypally inherits from the Error constructor.
function MyError(message) {
  this.name = "MyError";
  this.message = message || "Default Message";
  this.stack = new Error().stack;
}
MyError.prototype = Object.create(Error.prototype);
MyError.prototype.constructor = MyError;

try {
  throw new MyError();
} catch (e) {
  console.log(e.name); // 'MyError'
  console.log(e.message); // 'Default Message'
}

try {
  throw new MyError("custom message");
} catch (e) {
  console.log(e.name); // 'MyError'
  console.log(e.message); // 'custom message'
}
// cookie 的存储

// https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Cookies
